package com.keyinong.parkin.home.adapter;

import java.util.ArrayList;

import com.example.parkin.R;
import com.keyinong.parkin.home.bean.TicketBean;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class TicketAdapter extends BaseAdapter {
	Context context;
	ArrayList<TicketBean> list;
	int isNo;

	public TicketAdapter(Context context, ArrayList<TicketBean> list,int isNo) {
		super();
		this.context = context;
		this.list = list;
        this.isNo=isNo;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHandle handle;
		if (view == null) {
			handle = new ViewHandle();
			view = LayoutInflater.from(context).inflate(
					R.layout.item_list_ticket, null);
			handle.tv_ticketTitle = (TextView) view
					.findViewById(R.id.tv_ticketTitle);
			handle.tv_ticketContent = (TextView) view
					.findViewById(R.id.tv_ticketContent);
			view.setTag(handle);
		}else{
			handle=(ViewHandle) view.getTag();
		}
		if(isNo==1){
			handle.tv_ticketTitle.setBackgroundResource(R.drawable.img_ticket_title);
		}else{
			handle.tv_ticketTitle.setBackgroundResource(R.drawable.img_order_noprocess);
		}
		handle.tv_ticketTitle.setText(list.get(position).getSubject());
		handle.tv_ticketContent.setText(list.get(position).getContent());
		return view;
	}

	private class ViewHandle {
		TextView tv_ticketTitle;
		TextView tv_ticketContent;
	}

}
